﻿using FaceCat;
using facecat_avalonia;
using Microsoft.Graphics.Canvas.UI.Xaml;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml.Shapes;

// https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板

namespace facecat_winui
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class MainPage : Page, FCTouchEventCallBack
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();
            onLoad();
        }

        /// <summary>
        /// 是否双击
        /// </summary>
        private bool m_isDoubleClick;

        /// <summary>
        /// 公共方法库
        /// </summary>
        public FCNative m_native;

        /// <summary>
        /// 设备对接
        /// </summary>
        public UWPHost m_host;

        /// <summary>
        /// 配置解析
        /// </summary>
        public FCUIXml m_xml;

        /// <summary>
        /// 重绘事件
        /// </summary>
        /// <param name="sender">调用者</param>
        /// <param name="args">参数</param>
        public void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            if (m_host.m_canvas == null)
            {
                m_host.m_canvas = sender;
                sender.PointerPressed += Sender_PointerPressed;
                sender.PointerReleased += Sender_PointerReleased;
                sender.PointerMoved += Sender_PointerMoved;
                sender.PointerWheelChanged += Sender_PointerWheelChanged;
            }
            int width = (int)sender.Size.Width, height = (int)sender.Size.Height;
            FCSize oldSize = m_native.getSize();
            if (width > 0 && height > 0)
            {
                if (oldSize.cx != width || oldSize.cy != height)
                {
                    m_native.setSize(new FCSize(width, height));
                    m_native.update();
                }
            }
            UWPPaint aPaint = m_native.getPaint() as UWPPaint;
            aPaint.m_args = args;
            aPaint.m_canvas = sender;
            FCRect clipRect = new FCRect(0, 0, m_native.getSize().cx, m_native.getSize().cy);
            aPaint.beginPaint(IntPtr.Zero, clipRect, clipRect);
            m_native.onPaint(clipRect);
            aPaint.endPaint();
        }

        /// <summary>
        /// 鼠标滚轮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Sender_PointerWheelChanged(object sender, PointerRoutedEventArgs e)
        {
            if (m_host.allowOperate())
            {
                FCTouchInfo newTouchInfo = new FCTouchInfo();
                newTouchInfo.m_delta = e.GetCurrentPoint(sender as UIElement).Properties.MouseWheelDelta;
                m_native.onMouseWheel(newTouchInfo);
            }
        }

        /// <summary>
        /// 鼠标松开事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Sender_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            Point point = e.GetCurrentPoint(sender as UIElement).Position;
            m_host.m_touchPoint = new FCPoint((int)point.X, (int)point.Y);
            if (m_host.allowOperate())
            {
                FCTouchInfo newTouchInfo = new FCTouchInfo();
                newTouchInfo.m_firstTouch = true;
                newTouchInfo.m_buttons = 1;
                newTouchInfo.m_clicks = m_isDoubleClick ? 2 : 1;
                m_native.onMouseUp(newTouchInfo);
            }
        }

        /// <summary>
        /// 鼠标移动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Sender_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            Point point = e.GetCurrentPoint(sender as UIElement).Position;
            m_host.m_touchPoint = new FCPoint((int)point.X, (int)point.Y);
            if (m_host.allowOperate())
            {
                if (m_native.m_touchDownView != null)
                {
                    FCTouchInfo newTouchInfo = new FCTouchInfo();
                    newTouchInfo.m_firstTouch = true;
                    newTouchInfo.m_buttons = 1;
                    newTouchInfo.m_clicks = 1;
                    m_native.onMouseMove(newTouchInfo);
                }
                else
                {
                    FCTouchInfo newTouchInfo = new FCTouchInfo();
                    m_native.onMouseMove(newTouchInfo);
                }
            }
        }

        /// <summary>
        /// 上次点击时间
        /// </summary>
        public DateTime m_lastMouseDownTime = DateTime.Now;

        /// <summary>
        /// 鼠标按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Sender_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Point point = e.GetCurrentPoint(sender as UIElement).Position;
            m_host.m_touchPoint = new FCPoint((int)point.X, (int)point.Y);
            DateTime nowTime = DateTime.Now;
            long ticks = (DateTime.Now - m_lastMouseDownTime).Ticks;
            m_isDoubleClick = ticks < 10000 * 200;
            m_lastMouseDownTime = nowTime;
            if (m_host.allowOperate())
            {
                FCTouchInfo newTouchInfo = new FCTouchInfo();
                newTouchInfo.m_firstTouch = true;
                newTouchInfo.m_buttons = 1;
                newTouchInfo.m_clicks = m_isDoubleClick ? 2 : 1;
                m_native.onMouseDown(newTouchInfo);
            }
        }

        /// <summary>
        /// 加载视图
        /// </summary>
        public void onLoad()
        {
            m_xml = new FCUIXml();
            m_xml.createNative();
            m_native = m_xml.getNative();
            m_native.setPaint(new UWPPaint());
            m_host = new UWPHost();
            //m_host.m_view = this;
            m_native.setHost(m_host);
            m_host.setNative(m_native);
            m_native.setSize(new FCSize(800, 700));
            string xml = @"<?xml version=""1.0"" encoding=""utf-8""?>
    <html xmlns=""facecat"">
    <head>
    </head>
    <body>
      <div dock=""fill"" type=""tab"" selectedindex=""0"" name=""TabView"">
        <div name=""TabPage"" text=""图表"" type=""tabpage"">
          <chart size=""200,200"" name=""Chart"" text=""Chart"" location=""212,164"" dock=""Fill"" cursor=""Hand"">
          </chart>
        </div>
        <div name=""TabPage2"" text=""指标"" type=""tabpage"" />
        <div name=""TabPage3"" text=""画线"" type=""tabpage"" />
      </div>
    </body>
    </html>";
            m_xml.loadXml(xml, null);
            m_native.update();

            FCChart chart = m_xml.getChart("Chart");
            if (chart != null)
            {
                chart.m_allowDragChartDiv = true;
                chart.m_cycle = "day";
                chart.addEvent(this, FCEventID.TouchDown, this);
                chartToBlack(chart);
                m_tChart = chart;
                FCTabPage tabPage2 = m_xml.getTabPage("TabPage2");
                FCTabPage tabPage3 = m_xml.getTabPage("TabPage3");
                ArrayList<SecurityData> securityDatas = getSecurityDatas();
                chart.m_rightVScaleWidth = 80;
                chart.m_data = securityDatas;
                chart.m_mainIndicator = "BOLL"; //主图指标
                chart.m_showIndicator = "MACD"; //显示指标
                chart.resetChartVisibleRecord();
                chart.checkChartLastVisibleIndex();
                chart.calcChartIndicator();
                FCLayoutDiv indLayout = new FCLayoutDiv();
                indLayout.setLocation(new FCPoint(0, 0));
                indLayout.setSize(new FCSize(tabPage2.getWidth(), tabPage2.getHeight()));
                indLayout.setAutoWrap(true);
                indLayout.setBackColor(FCColor.rgb(0, 0, 0));
                indLayout.setDock(FCDockStyle.Fill);
                tabPage2.addView(indLayout);
                ArrayList<String> indicators = new ArrayList<String>();
                indicators.add("MA");
                indicators.add("BOLL");
                indicators.add("MACD");
                indicators.add("KDJ");
                indicators.add("BIAS");
                indicators.add("BBI");
                indicators.add("RSI");
                indicators.add("ROC");
                indicators.add("WR");
                indicators.add("DMA");
                indicators.add("TRIX");
                indicators.add("CCI");
                for (int i = 0; i < indicators.size(); i++)
                {
                    FCButton button = new FCButton();
                    button.setText(indicators[i]);
                    button.setName("Indicator");
                    button.setSize(new FCSize(100, 50));
                    button.setMargin(new FCPadding(10, 10, 10, 10));
                    button.setBackColor(FCColor.rgb(0, 0, 0));
                    button.setTextColor(FCColor.rgb(255, 255, 255));
                    button.setBorderColor(FCColor.rgb(100, 100, 100));
                    button.addEvent(this, FCEventID.Click, this);
                    indLayout.addView(button);
                }

                FCLayoutDiv indLayout2 = new FCLayoutDiv();
                indLayout2.setLocation(new FCPoint(0, 0));
                indLayout2.setSize(new FCSize(tabPage3.getWidth(), tabPage3.getHeight()));
                indLayout2.setAutoWrap(true);
                indLayout2.setBackColor(FCColor.rgb(0, 0, 0));
                indLayout2.setDock(FCDockStyle.Fill);
                tabPage3.addView(indLayout2);

                ArrayList<String> plots = new ArrayList<string>();
                plots.add("Line");
                plots.add("Segment");
                plots.add("Ray");
                plots.add("Triangle");
                plots.add("Rect");
                plots.add("Cycle");
                plots.add("CircumCycle");
                plots.add("Ellipse");
                plots.add("AngleLine");
                plots.add("LRLine");
                plots.add("LRChannel");
                plots.add("SymmetricTriangle");
                plots.add("LRBand");
                plots.add("ParalleGram");
                plots.add("SpeedResist");
                plots.add("FiboFanline");
                plots.add("FiboTimezone");
                plots.add("Percent");
                plots.add("BoxLine");
                plots.add("TironeLevels");
                plots.add("QuadrantLines");
                plots.add("Parallel");
                plots.add("GoldenRatio");
                plots.add("ArrowSegment");
                for (int i = 0; i < plots.size(); i++)
                {
                    FCButton button = new FCButton();
                    button.setText(plots[i]);
                    button.setName("Plot");
                    button.setSize(new FCSize(100, 50));
                    button.setMargin(new FCPadding(10, 10, 10, 10));
                    button.setBackColor(FCColor.rgb(0, 0, 0));
                    button.setTextColor(FCColor.rgb(255, 255, 255));
                    button.addEvent(this, FCEventID.Click, this);
                    button.setBorderColor(FCColor.rgb(100, 100, 100));
                    indLayout2.addView(button);
                }
            }
            m_native.update();
            m_native.invalidate();
        }

        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public ArrayList<SecurityData> getSecurityDatas()
        {
            ArrayList<SecurityData> securityDatas = new ArrayList<SecurityData>();
            SecurityData sData1 = new SecurityData();
            sData1.m_volume = 78469.756458;
            sData1.m_close = 15684.25;
            sData1.m_high = 15965.01;
            sData1.m_low = 15272.69;
            sData1.m_open = 15297.22;
            sData1.m_date = 1605052800.0;
            securityDatas.add(sData1);
            SecurityData sData2 = new SecurityData();
            sData2.m_volume = 102196.366592;
            sData2.m_close = 16291.87;
            sData2.m_high = 16340.71;
            sData2.m_low = 15440.65;
            sData2.m_open = 15684.26;
            sData2.m_date = 1605139200.0;
            securityDatas.add(sData2);
            SecurityData sData3 = new SecurityData();
            sData3.m_volume = 75691.891014;
            sData3.m_close = 16320.71;
            sData3.m_high = 16480.01;
            sData3.m_low = 15952.36;
            sData3.m_open = 16291.86;
            sData3.m_date = 1605225600.0;
            securityDatas.add(sData3);
            SecurityData sData4 = new SecurityData();
            sData4.m_volume = 59116.357179;
            sData4.m_close = 16070.46;
            sData4.m_high = 16327.0;
            sData4.m_low = 15670.01;
            sData4.m_open = 16320.05;
            sData4.m_date = 1605312000.0;
            securityDatas.add(sData4);
            SecurityData sData5 = new SecurityData();
            sData5.m_volume = 43596.851513;
            sData5.m_close = 15957.01;
            sData5.m_high = 16180.01;
            sData5.m_low = 15774.73;
            sData5.m_open = 16069.57;
            sData5.m_date = 1605398400.0;
            securityDatas.add(sData5);
            SecurityData sData6 = new SecurityData();
            sData6.m_volume = 81300.685924;
            sData6.m_close = 16713.58;
            sData6.m_high = 16880.01;
            sData6.m_low = 15864.01;
            sData6.m_open = 15957.01;
            sData6.m_date = 1605484800.0;
            securityDatas.add(sData6);
            SecurityData sData7 = new SecurityData();
            sData7.m_volume = 115192.02613;
            sData7.m_close = 17659.39;
            sData7.m_high = 17858.83;
            sData7.m_low = 16538.01;
            sData7.m_open = 16713.09;
            sData7.m_date = 1605571200.0;
            securityDatas.add(sData7);
            SecurityData sData8 = new SecurityData();
            sData8.m_volume = 141984.264415;
            sData8.m_close = 17776.13;
            sData8.m_high = 18476.94;
            sData8.m_low = 17222.01;
            sData8.m_open = 17659.39;
            sData8.m_date = 1605657600.0;
            securityDatas.add(sData8);
            SecurityData sData9 = new SecurityData();
            sData9.m_volume = 93009.571008;
            sData9.m_close = 17802.83;
            sData9.m_high = 18179.81;
            sData9.m_low = 17335.66;
            sData9.m_open = 17777.76;
            sData9.m_date = 1605744000.0;
            securityDatas.add(sData9);
            SecurityData sData10 = new SecurityData();
            sData10.m_volume = 88423.028489;
            sData10.m_close = 18655.68;
            sData10.m_high = 18815.23;
            sData10.m_low = 17740.05;
            sData10.m_open = 17802.82;
            sData10.m_date = 1605830400.0;
            securityDatas.add(sData10);
            SecurityData sData11 = new SecurityData();
            sData11.m_volume = 71308.137138;
            sData11.m_close = 18703.81;
            sData11.m_high = 18965.91;
            sData11.m_low = 18308.59;
            sData11.m_open = 18655.67;
            sData11.m_date = 1605916800.0;
            securityDatas.add(sData11);
            SecurityData sData12 = new SecurityData();
            sData12.m_volume = 74492.806006;
            sData12.m_close = 18414.61;
            sData12.m_high = 18750.01;
            sData12.m_low = 17699.8;
            sData12.m_open = 18703.81;
            sData12.m_date = 1606003200.0;
            securityDatas.add(sData12);
            SecurityData sData13 = new SecurityData();
            sData13.m_volume = 74179.661546;
            sData13.m_close = 18368.01;
            sData13.m_high = 18766.01;
            sData13.m_low = 18000.01;
            sData13.m_open = 18413.89;
            sData13.m_date = 1606089600.0;
            securityDatas.add(sData13);
            SecurityData sData14 = new SecurityData();
            sData14.m_volume = 70126.693681;
            sData14.m_close = 19160.02;
            sData14.m_high = 19410.0;
            sData14.m_low = 18207.99;
            sData14.m_open = 18368.02;
            sData14.m_date = 1606176000.0;
            securityDatas.add(sData14);
            SecurityData sData15 = new SecurityData();
            sData15.m_volume = 70760.56353;
            sData15.m_close = 18719.12;
            sData15.m_high = 19444.01;
            sData15.m_low = 18570.01;
            sData15.m_open = 19160.01;
            sData15.m_date = 1606262400.0;
            securityDatas.add(sData15);
            SecurityData sData16 = new SecurityData();
            sData16.m_volume = 102420.321403;
            sData16.m_close = 17149.48;
            sData16.m_high = 18915.04;
            sData16.m_low = 16188.01;
            sData16.m_open = 18718.84;
            sData16.m_date = 1606348800.0;
            securityDatas.add(sData16);
            SecurityData sData17 = new SecurityData();
            sData17.m_volume = 84036.578341;
            sData17.m_close = 17139.53;
            sData17.m_high = 17457.63;
            sData17.m_low = 16438.09;
            sData17.m_open = 17149.48;
            sData17.m_date = 1606435200.0;
            securityDatas.add(sData17);
            SecurityData sData18 = new SecurityData();
            sData18.m_volume = 60835.734083;
            sData18.m_close = 17719.86;
            sData18.m_high = 17880.5;
            sData18.m_low = 16865.57;
            sData18.m_open = 17139.54;
            sData18.m_date = 1606521600.0;
            securityDatas.add(sData18);
            SecurityData sData19 = new SecurityData();
            sData19.m_volume = 55329.026303;
            sData19.m_close = 18185.0;
            sData19.m_high = 18360.06;
            sData19.m_low = 17517.01;
            sData19.m_open = 17719.85;
            sData19.m_date = 1606608000.0;
            securityDatas.add(sData19);
            SecurityData sData20 = new SecurityData();
            sData20.m_volume = 96227.350495;
            sData20.m_close = 19695.88;
            sData20.m_high = 19777.04;
            sData20.m_low = 18185.0;
            sData20.m_open = 18185.01;
            sData20.m_date = 1606694400.0;
            securityDatas.add(sData20);
            SecurityData sData21 = new SecurityData();
            sData21.m_volume = 100331.141203;
            sData21.m_close = 18764.97;
            sData21.m_high = 19888.01;
            sData21.m_low = 18350.0;
            sData21.m_open = 19695.88;
            sData21.m_date = 1606780800.0;
            securityDatas.add(sData21);
            SecurityData sData22 = new SecurityData();
            sData22.m_volume = 75848.875728;
            sData22.m_close = 19204.1;
            sData22.m_high = 19342.01;
            sData22.m_low = 18330.01;
            sData22.m_open = 18764.97;
            sData22.m_date = 1606867200.0;
            securityDatas.add(sData22);
            SecurityData sData23 = new SecurityData();
            sData23.m_volume = 64987.682732;
            sData23.m_close = 19421.91;
            sData23.m_high = 19598.01;
            sData23.m_low = 18867.21;
            sData23.m_open = 19204.09;
            sData23.m_date = 1606953600.0;
            securityDatas.add(sData23);
            SecurityData sData24 = new SecurityData();
            sData24.m_volume = 65481.220724;
            sData24.m_close = 18650.53;
            sData24.m_high = 19527.01;
            sData24.m_low = 18565.32;
            sData24.m_open = 19422.35;
            sData24.m_date = 1607040000.0;
            securityDatas.add(sData24);
            SecurityData sData25 = new SecurityData();
            sData25.m_volume = 42922.758573;
            sData25.m_close = 19147.67;
            sData25.m_high = 19177.01;
            sData25.m_low = 18500.01;
            sData25.m_open = 18650.52;
            sData25.m_date = 1607126400.0;
            securityDatas.add(sData25);
            SecurityData sData26 = new SecurityData();
            sData26.m_volume = 37043.101861;
            sData26.m_close = 19359.41;
            sData26.m_high = 19420.01;
            sData26.m_low = 18857.01;
            sData26.m_open = 19147.67;
            sData26.m_date = 1607212800.0;
            securityDatas.add(sData26);
            SecurityData sData27 = new SecurityData();
            sData27.m_volume = 40833.661907;
            sData27.m_close = 19166.91;
            sData27.m_high = 19420.92;
            sData27.m_low = 18902.89;
            sData27.m_open = 19358.68;
            sData27.m_date = 1607299200.0;
            securityDatas.add(sData27);
            SecurityData sData28 = new SecurityData();
            sData28.m_volume = 56080.515386;
            sData28.m_close = 18324.12;
            sData28.m_high = 19294.85;
            sData28.m_low = 18200.01;
            sData28.m_open = 19166.91;
            sData28.m_date = 1607385600.0;
            securityDatas.add(sData28);
            SecurityData sData29 = new SecurityData();
            sData29.m_volume = 75498.213856;
            sData29.m_close = 18541.29;
            sData29.m_high = 18639.58;
            sData29.m_low = 17650.01;
            sData29.m_open = 18324.12;
            sData29.m_date = 1607472000.0;
            securityDatas.add(sData29);
            SecurityData sData30 = new SecurityData();
            sData30.m_volume = 52890.685094;
            sData30.m_close = 18254.64;
            sData30.m_high = 18557.33;
            sData30.m_low = 17911.13;
            sData30.m_open = 18541.3;
            sData30.m_date = 1607558400.0;
            securityDatas.add(sData30);
            SecurityData sData31 = new SecurityData();
            sData31.m_volume = 72610.734259;
            sData31.m_close = 18036.54;
            sData31.m_high = 18292.74;
            sData31.m_low = 17572.34;
            sData31.m_open = 18254.82;
            sData31.m_date = 1607644800.0;
            securityDatas.add(sData31);
            SecurityData sData32 = new SecurityData();
            sData32.m_volume = 47592.761572;
            sData32.m_close = 18808.7;
            sData32.m_high = 18948.67;
            sData32.m_low = 18020.71;
            sData32.m_open = 18036.54;
            sData32.m_date = 1607731200.0;
            securityDatas.add(sData32);
            SecurityData sData33 = new SecurityData();
            sData33.m_volume = 56560.831744;
            sData33.m_close = 19175.0;
            sData33.m_high = 19411.01;
            sData33.m_low = 18711.13;
            sData33.m_open = 18808.7;
            sData33.m_date = 1607817600.0;
            securityDatas.add(sData33);
            SecurityData sData34 = new SecurityData();
            sData34.m_volume = 47257.211294;
            sData34.m_close = 19273.15;
            sData34.m_high = 19349.01;
            sData34.m_low = 19000.01;
            sData34.m_open = 19175.0;
            sData34.m_date = 1607904000.0;
            securityDatas.add(sData34);
            SecurityData sData35 = new SecurityData();
            sData35.m_volume = 61792.483421;
            sData35.m_close = 19426.44;
            sData35.m_high = 19570.01;
            sData35.m_low = 19050.01;
            sData35.m_open = 19273.7;
            sData35.m_date = 1607990400.0;
            securityDatas.add(sData35);
            SecurityData sData36 = new SecurityData();
            sData36.m_volume = 97061.040854;
            sData36.m_close = 21335.53;
            sData36.m_high = 21560.01;
            sData36.m_low = 19278.61;
            sData36.m_open = 19426.44;
            sData36.m_date = 1608076800.0;
            securityDatas.add(sData36);
            SecurityData sData37 = new SecurityData();
            sData37.m_volume = 148769.444419;
            sData37.m_close = 22808.99;
            sData37.m_high = 23699.71;
            sData37.m_low = 21233.01;
            sData37.m_open = 21335.53;
            sData37.m_date = 1608163200.0;
            securityDatas.add(sData37);
            SecurityData sData38 = new SecurityData();
            sData38.m_volume = 79646.144315;
            sData38.m_close = 23107.4;
            sData38.m_high = 23285.19;
            sData38.m_low = 22350.01;
            sData38.m_open = 22797.16;
            sData38.m_date = 1608249600.0;
            securityDatas.add(sData38);
            SecurityData sData39 = new SecurityData();
            sData39.m_volume = 82430.712232;
            sData39.m_close = 23821.62;
            sData39.m_high = 24171.48;
            sData39.m_low = 22750.01;
            sData39.m_open = 23107.4;
            sData39.m_date = 1608336000.0;
            securityDatas.add(sData39);
            SecurityData sData40 = new SecurityData();
            sData40.m_volume = 74797.201958;
            sData40.m_close = 23455.53;
            sData40.m_high = 24295.01;
            sData40.m_low = 23060.01;
            sData40.m_open = 23821.61;
            sData40.m_date = 1608422400.0;
            securityDatas.add(sData40);
            SecurityData sData41 = new SecurityData();
            sData41.m_volume = 83424.441428;
            sData41.m_close = 22719.72;
            sData41.m_high = 24102.78;
            sData41.m_low = 21815.01;
            sData41.m_open = 23455.55;
            sData41.m_date = 1608508800.0;
            securityDatas.add(sData41);
            SecurityData sData42 = new SecurityData();
            sData42.m_volume = 87033.13616;
            sData42.m_close = 23810.8;
            sData42.m_high = 23837.11;
            sData42.m_low = 22353.41;
            sData42.m_open = 22719.89;
            sData42.m_date = 1608595200.0;
            securityDatas.add(sData42);
            SecurityData sData43 = new SecurityData();
            sData43.m_volume = 112830.021287;
            sData43.m_close = 23232.77;
            sData43.m_high = 24100.01;
            sData43.m_low = 22810.01;
            sData43.m_open = 23810.8;
            sData43.m_date = 1608681600.0;
            securityDatas.add(sData43);
            SecurityData sData44 = new SecurityData();
            sData44.m_volume = 69013.844252;
            sData44.m_close = 23729.21;
            sData44.m_high = 23794.44;
            sData44.m_low = 22703.43;
            sData44.m_open = 23232.4;
            sData44.m_date = 1608768000.0;
            securityDatas.add(sData44);
            SecurityData sData45 = new SecurityData();
            sData45.m_volume = 78024.251646;
            sData45.m_close = 24712.48;
            sData45.m_high = 24789.87;
            sData45.m_low = 23434.74;
            sData45.m_open = 23729.0;
            sData45.m_date = 1608854400.0;
            securityDatas.add(sData45);
            SecurityData sData46 = new SecurityData();
            sData46.m_volume = 97806.523386;
            sData46.m_close = 26493.4;
            sData46.m_high = 26867.04;
            sData46.m_low = 24500.01;
            sData46.m_open = 24712.48;
            sData46.m_date = 1608940800.0;
            securityDatas.add(sData46);
            SecurityData sData47 = new SecurityData();
            sData47.m_volume = 145880.8092;
            sData47.m_close = 26281.67;
            sData47.m_high = 28422.01;
            sData47.m_low = 25700.01;
            sData47.m_open = 26493.41;
            sData47.m_date = 1609027200.0;
            securityDatas.add(sData47);
            SecurityData sData48 = new SecurityData();
            sData48.m_volume = 79408.740817;
            sData48.m_close = 27079.42;
            sData48.m_high = 27500.01;
            sData48.m_low = 26101.01;
            sData48.m_open = 26281.55;
            sData48.m_date = 1609113600.0;
            securityDatas.add(sData48);
            SecurityData sData49 = new SecurityData();
            sData49.m_volume = 69255.341092;
            sData49.m_close = 27385.01;
            sData49.m_high = 27410.01;
            sData49.m_low = 25880.01;
            sData49.m_open = 27079.43;
            sData49.m_date = 1609200000.0;
            securityDatas.add(sData49);
            SecurityData sData50 = new SecurityData();
            sData50.m_volume = 95356.067826;
            sData50.m_close = 28875.55;
            sData50.m_high = 28996.01;
            sData50.m_low = 27320.01;
            sData50.m_open = 27385.01;
            sData50.m_date = 1609286400.0;
            securityDatas.add(sData50);
            SecurityData sData51 = new SecurityData();
            sData51.m_volume = 75491.419522;
            sData51.m_close = 28923.64;
            sData51.m_high = 29300.01;
            sData51.m_low = 27850.01;
            sData51.m_open = 28875.56;
            sData51.m_date = 1609372800.0;
            securityDatas.add(sData51);
            SecurityData sData52 = new SecurityData();
            sData52.m_volume = 54134.113624;
            sData52.m_close = 29331.7;
            sData52.m_high = 29600.01;
            sData52.m_low = 28624.58;
            sData52.m_open = 28923.64;
            sData52.m_date = 1609459200.0;
            securityDatas.add(sData52);
            SecurityData sData53 = new SecurityData();
            sData53.m_volume = 126100.088124;
            sData53.m_close = 32178.34;
            sData53.m_high = 33300.01;
            sData53.m_low = 28946.54;
            sData53.m_open = 29331.71;
            sData53.m_date = 1609545600.0;
            securityDatas.add(sData53);
            SecurityData sData54 = new SecurityData();
            sData54.m_volume = 110771.806254;
            sData54.m_close = 33000.06;
            sData54.m_high = 34778.12;
            sData54.m_low = 31963.0;
            sData54.m_open = 32176.46;
            sData54.m_date = 1609632000.0;
            securityDatas.add(sData54);
            SecurityData sData55 = new SecurityData();
            sData55.m_volume = 121030.155465;
            sData55.m_close = 31988.72;
            sData55.m_high = 33600.01;
            sData55.m_low = 28130.01;
            sData55.m_open = 33000.06;
            sData55.m_date = 1609718400.0;
            securityDatas.add(sData55);
            SecurityData sData56 = new SecurityData();
            sData56.m_volume = 111890.475678;
            sData56.m_close = 33949.54;
            sData56.m_high = 34360.01;
            sData56.m_low = 29900.01;
            sData56.m_open = 31989.76;
            sData56.m_date = 1609804800.0;
            securityDatas.add(sData56);
            SecurityData sData57 = new SecurityData();
            sData57.m_volume = 116093.037717;
            sData57.m_close = 36769.37;
            sData57.m_high = 36939.22;
            sData57.m_low = 33288.01;
            sData57.m_open = 33949.54;
            sData57.m_date = 1609891200.0;
            securityDatas.add(sData57);
            SecurityData sData58 = new SecurityData();
            sData58.m_volume = 121506.449096;
            sData58.m_close = 39432.29;
            sData58.m_high = 40365.01;
            sData58.m_low = 36300.01;
            sData58.m_open = 36769.37;
            sData58.m_date = 1609977600.0;
            securityDatas.add(sData58);
            SecurityData sData59 = new SecurityData();
            sData59.m_volume = 138625.042444;
            sData59.m_close = 40582.82;
            sData59.m_high = 41950.01;
            sData59.m_low = 36500.01;
            sData59.m_open = 39432.49;
            sData59.m_date = 1610064000.0;
            securityDatas.add(sData59);
            SecurityData sData60 = new SecurityData();
            sData60.m_volume = 75785.989675;
            sData60.m_close = 40088.23;
            sData60.m_high = 41380.01;
            sData60.m_low = 38720.01;
            sData60.m_open = 40586.97;
            sData60.m_date = 1610150400.0;
            securityDatas.add(sData60);
            SecurityData sData61 = new SecurityData();
            sData61.m_volume = 112638.990321;
            sData61.m_close = 38150.03;
            sData61.m_high = 41350.01;
            sData61.m_low = 35111.12;
            sData61.m_open = 40088.23;
            sData61.m_date = 1610236800.0;
            securityDatas.add(sData61);
            SecurityData sData62 = new SecurityData();
            sData62.m_volume = 231175.583454;
            sData62.m_close = 35404.48;
            sData62.m_high = 38264.75;
            sData62.m_low = 30420.01;
            sData62.m_open = 38150.03;
            sData62.m_date = 1610323200.0;
            securityDatas.add(sData62);
            SecurityData sData63 = new SecurityData();
            sData63.m_volume = 133948.161996;
            sData63.m_close = 34051.25;
            sData63.m_high = 36628.01;
            sData63.m_low = 32531.01;
            sData63.m_open = 35410.38;
            sData63.m_date = 1610409600.0;
            securityDatas.add(sData63);
            SecurityData sData64 = new SecurityData();
            sData64.m_volume = 124477.924938;
            sData64.m_close = 37371.39;
            sData64.m_high = 37850.01;
            sData64.m_low = 32380.01;
            sData64.m_open = 34049.16;
            sData64.m_date = 1610496000.0;
            securityDatas.add(sData64);
            SecurityData sData65 = new SecurityData();
            sData65.m_volume = 102950.399421;
            sData65.m_close = 39144.51;
            sData65.m_high = 40100.01;
            sData65.m_low = 36701.24;
            sData65.m_open = 37371.39;
            sData65.m_date = 1610582400.0;
            securityDatas.add(sData65);
            SecurityData sData66 = new SecurityData();
            sData66.m_volume = 111365.804668;
            sData66.m_close = 36742.23;
            sData66.m_high = 39747.77;
            sData66.m_low = 34538.89;
            sData66.m_open = 39145.22;
            sData66.m_date = 1610668800.0;
            securityDatas.add(sData66);
            SecurityData sData67 = new SecurityData();
            sData67.m_volume = 86348.441508;
            sData67.m_close = 35994.99;
            sData67.m_high = 37950.01;
            sData67.m_low = 35357.81;
            sData67.m_open = 36737.44;
            sData67.m_date = 1610755200.0;
            securityDatas.add(sData67);
            SecurityData sData68 = new SecurityData();
            sData68.m_volume = 80157.737384;
            sData68.m_close = 35828.62;
            sData68.m_high = 36852.51;
            sData68.m_low = 33850.01;
            sData68.m_open = 35994.99;
            sData68.m_date = 1610841600.0;
            securityDatas.add(sData68);
            SecurityData sData69 = new SecurityData();
            sData69.m_volume = 70693.90404;
            sData69.m_close = 36631.28;
            sData69.m_high = 37469.84;
            sData69.m_low = 34800.01;
            sData69.m_open = 35825.0;
            sData69.m_date = 1610928000.0;
            securityDatas.add(sData69);
            SecurityData sData70 = new SecurityData();
            sData70.m_volume = 79596.541309;
            sData70.m_close = 35891.5;
            sData70.m_high = 37850.01;
            sData70.m_low = 35844.07;
            sData70.m_open = 36622.47;
            sData70.m_date = 1611014400.0;
            securityDatas.add(sData70);
            SecurityData sData71 = new SecurityData();
            sData71.m_volume = 89368.432918;
            sData71.m_close = 35468.24;
            sData71.m_high = 36415.32;
            sData71.m_low = 33400.01;
            sData71.m_open = 35901.95;
            sData71.m_date = 1611100800.0;
            securityDatas.add(sData71);
            SecurityData sData72 = new SecurityData();
            sData72.m_volume = 134548.811336;
            sData72.m_close = 30850.14;
            sData72.m_high = 35600.01;
            sData72.m_low = 30071.01;
            sData72.m_open = 35468.24;
            sData72.m_date = 1611187200.0;
            securityDatas.add(sData72);
            SecurityData sData73 = new SecurityData();
            sData73.m_volume = 138345.853436;
            sData73.m_close = 32945.18;
            sData73.m_high = 33826.54;
            sData73.m_low = 28850.01;
            sData73.m_open = 30852.0;
            sData73.m_date = 1611273600.0;
            securityDatas.add(sData73);
            SecurityData sData74 = new SecurityData();
            sData74.m_volume = 64595.297675;
            sData74.m_close = 32078.01;
            sData74.m_high = 33456.01;
            sData74.m_low = 31390.17;
            sData74.m_open = 32950.01;
            sData74.m_date = 1611360000.0;
            securityDatas.add(sData74);
            SecurityData sData75 = new SecurityData();
            sData75.m_volume = 57978.047966;
            sData75.m_close = 32259.91;
            sData75.m_high = 33071.01;
            sData75.m_low = 30900.01;
            sData75.m_open = 32078.01;
            sData75.m_date = 1611446400.0;
            securityDatas.add(sData75);
            SecurityData sData76 = new SecurityData();
            sData76.m_volume = 88499.236921;
            sData76.m_close = 32254.21;
            sData76.m_high = 34875.01;
            sData76.m_low = 31910.01;
            sData76.m_open = 32259.46;
            sData76.m_date = 1611532800.0;
            securityDatas.add(sData76);
            SecurityData sData77 = new SecurityData();
            sData77.m_volume = 84866.207055;
            sData77.m_close = 32467.78;
            sData77.m_high = 32921.89;
            sData77.m_low = 30837.38;
            sData77.m_open = 32254.2;
            sData77.m_date = 1611619200.0;
            securityDatas.add(sData77);
            SecurityData sData78 = new SecurityData();
            sData78.m_volume = 95911.971711;
            sData78.m_close = 30366.16;
            sData78.m_high = 32557.3;
            sData78.m_low = 29241.73;
            sData78.m_open = 32464.02;
            sData78.m_date = 1611705600.0;
            securityDatas.add(sData78);
            SecurityData sData79 = new SecurityData();
            sData79.m_volume = 92621.155617;
            sData79.m_close = 33364.87;
            sData79.m_high = 33783.99;
            sData79.m_low = 29842.11;
            sData79.m_open = 30362.2;
            sData79.m_date = 1611792000.0;
            securityDatas.add(sData79);
            SecurityData sData80 = new SecurityData();
            sData80.m_volume = 193388.622446;
            sData80.m_close = 34252.21;
            sData80.m_high = 38531.91;
            sData80.m_low = 31915.41;
            sData80.m_open = 33368.19;
            sData80.m_date = 1611878400.0;
            securityDatas.add(sData80);
            SecurityData sData81 = new SecurityData();
            sData81.m_volume = 82674.758249;
            sData81.m_close = 34262.89;
            sData81.m_high = 34933.01;
            sData81.m_low = 32825.01;
            sData81.m_open = 34246.29;
            sData81.m_date = 1611964800.0;
            securityDatas.add(sData81);
            SecurityData sData82 = new SecurityData();
            sData82.m_volume = 66269.928016;
            sData82.m_close = 33092.99;
            sData82.m_high = 34342.7;
            sData82.m_low = 32171.68;
            sData82.m_open = 34262.9;
            sData82.m_date = 1612051200.0;
            securityDatas.add(sData82);
            SecurityData sData83 = new SecurityData();
            sData83.m_volume = 80154.567802;
            sData83.m_close = 33526.38;
            sData83.m_high = 34717.28;
            sData83.m_low = 32296.17;
            sData83.m_open = 33089.45;
            sData83.m_date = 1612137600.0;
            securityDatas.add(sData83);
            SecurityData sData84 = new SecurityData();
            sData84.m_volume = 78056.66988;
            sData84.m_close = 35466.25;
            sData84.m_high = 35984.34;
            sData84.m_low = 33418.01;
            sData84.m_open = 33517.1;
            sData84.m_date = 1612224000.0;
            securityDatas.add(sData84);
            SecurityData sData85 = new SecurityData();
            sData85.m_volume = 80784.343663;
            sData85.m_close = 37618.88;
            sData85.m_high = 37662.64;
            sData85.m_low = 35362.39;
            sData85.m_open = 35472.72;
            sData85.m_date = 1612310400.0;
            securityDatas.add(sData85);
            SecurityData sData86 = new SecurityData();
            sData86.m_volume = 89024.320756;
            sData86.m_close = 36936.67;
            sData86.m_high = 38708.28;
            sData86.m_low = 36161.96;
            sData86.m_open = 37620.27;
            sData86.m_date = 1612396800.0;
            securityDatas.add(sData86);
            SecurityData sData87 = new SecurityData();
            sData87.m_volume = 65910.531514;
            sData87.m_close = 38290.25;
            sData87.m_high = 38310.13;
            sData87.m_low = 36570.01;
            sData87.m_open = 36936.66;
            sData87.m_date = 1612483200.0;
            securityDatas.add(sData87);
            SecurityData sData88 = new SecurityData();
            sData88.m_volume = 94232.612846;
            sData88.m_close = 39186.95;
            sData88.m_high = 40955.52;
            sData88.m_low = 38215.95;
            sData88.m_open = 38289.33;
            sData88.m_date = 1612569600.0;
            securityDatas.add(sData88);
            SecurityData sData89 = new SecurityData();
            sData89.m_volume = 81820.439177;
            sData89.m_close = 38795.7;
            sData89.m_high = 39700.01;
            sData89.m_low = 37351.01;
            sData89.m_open = 39181.02;
            sData89.m_date = 1612656000.0;
            securityDatas.add(sData89);
            SecurityData sData90 = new SecurityData();
            sData90.m_volume = 121568.794672;
            sData90.m_close = 46374.88;
            sData90.m_high = 46794.46;
            sData90.m_low = 37988.9;
            sData90.m_open = 38795.7;
            sData90.m_date = 1612742400.0;
            securityDatas.add(sData90);
            SecurityData sData91 = new SecurityData();
            sData91.m_volume = 114567.009318;
            sData91.m_close = 46420.43;
            sData91.m_high = 48142.2;
            sData91.m_low = 44961.1;
            sData91.m_open = 46374.87;
            sData91.m_date = 1612828800.0;
            securityDatas.add(sData91);
            SecurityData sData92 = new SecurityData();
            sData92.m_volume = 78292.89657;
            sData92.m_close = 44807.59;
            sData92.m_high = 47310.01;
            sData92.m_low = 43800.01;
            sData92.m_open = 46420.43;
            sData92.m_date = 1612915200.0;
            securityDatas.add(sData92);
            SecurityData sData93 = new SecurityData();
            sData93.m_volume = 81033.184776;
            sData93.m_close = 47969.52;
            sData93.m_high = 48678.91;
            sData93.m_low = 43994.03;
            sData93.m_open = 44807.59;
            sData93.m_date = 1613001600.0;
            securityDatas.add(sData93);
            SecurityData sData94 = new SecurityData();
            sData94.m_volume = 81856.490636;
            sData94.m_close = 47287.61;
            sData94.m_high = 48985.81;
            sData94.m_low = 46400.01;
            sData94.m_open = 47968.67;
            sData94.m_date = 1613088000.0;
            securityDatas.add(sData94);
            SecurityData sData95 = new SecurityData();
            sData95.m_volume = 58937.84066;
            sData95.m_close = 47153.7;
            sData95.m_high = 48150.01;
            sData95.m_low = 46202.54;
            sData95.m_open = 47298.16;
            sData95.m_date = 1613174400.0;
            securityDatas.add(sData95);
            SecurityData sData96 = new SecurityData();
            sData96.m_volume = 70700.864117;
            sData96.m_close = 48577.8;
            sData96.m_high = 49707.44;
            sData96.m_low = 47014.18;
            sData96.m_open = 47156.79;
            sData96.m_date = 1613260800.0;
            securityDatas.add(sData96);
            SecurityData sData97 = new SecurityData();
            sData97.m_volume = 63227.659425;
            sData97.m_close = 47911.11;
            sData97.m_high = 49010.93;
            sData97.m_low = 46174.79;
            sData97.m_open = 48580.48;
            sData97.m_date = 1613347200.0;
            securityDatas.add(sData97);
            SecurityData sData98 = new SecurityData();
            sData98.m_volume = 78018.176005;
            sData98.m_close = 49133.46;
            sData98.m_high = 50080.22;
            sData98.m_low = 47003.63;
            sData98.m_open = 47911.11;
            sData98.m_date = 1613433600.0;
            securityDatas.add(sData98);
            SecurityData sData99 = new SecurityData();
            sData99.m_volume = 84886.224046;
            sData99.m_close = 52119.72;
            sData99.m_high = 52618.75;
            sData99.m_low = 48947.01;
            sData99.m_open = 49133.46;
            sData99.m_date = 1613520000.0;
            securityDatas.add(sData99);
            SecurityData sData100 = new SecurityData();
            sData100.m_volume = 58093.930825;
            sData100.m_close = 51552.61;
            sData100.m_high = 52530.01;
            sData100.m_low = 50901.91;
            sData100.m_open = 52117.68;
            sData100.m_date = 1613606400.0;
            securityDatas.add(sData100);
            return securityDatas;
        }

        /// <summary>
        /// 图表的黑色风格
        /// </summary>
        /// <param name="chart"></param>
        public void chartToBlack(FCChart chart)
        {
            chart.setBackColor(FCColor.rgb(0, 0, 0));
            chart.setTextColor(FCColor.rgb(255, 255, 255));
            chart.m_scaleColor = FCColor.rgb(100, 100, 100);
            chart.m_crossTipColor = FCColor.rgb(50, 50, 50);
            chart.m_crossLineColor = FCColor.rgb(100, 100, 100);
            chart.m_gridColor = FCColor.rgba(100, 100, 100, 125);
            ArrayList<long> indicatorColors = new ArrayList<long>();
            chart.m_indicatorColors = indicatorColors;
            indicatorColors.add(FCColor.rgb(255, 255, 255));
            indicatorColors.add(FCColor.rgb(255, 255, 0));
            indicatorColors.add(FCColor.rgb(255, 0, 255));
            indicatorColors.add(FCColor.rgb(255, 0, 0));
            indicatorColors.add(FCColor.rgb(0, 255, 255));
            indicatorColors.add(FCColor.rgb(0, 255, 0));
            indicatorColors.add(FCColor.rgb(255, 255, 0));
            indicatorColors.add(FCColor.rgb(255, 255, 255));
        }

        /// <summary>
        /// 图表
        /// </summary>
        public FCChart m_tChart;

        /// <summary>
        /// 触摸事件
        /// </summary>
        /// <param name="eventName">事件名称</param>
        /// <param name="sender">对象</param>
        /// <param name="touchInfo">触摸信息</param>
        /// <param name="invoke">调用者</param>
        public void callTouchEvent(string eventName, object sender, FCTouchInfo touchInfo, object invoke)
        {
            FCView view = sender as FCView;
            if (eventName == FCEventID.TouchDown)
            {
                if (view == m_tChart)
                {
                    FCChart chart = m_tChart;
                    if (chart.m_addingPlotChart.Length > 0)
                    {
                        chart.addPlotDefault(touchInfo.m_firstTouch, touchInfo.m_firstPoint, touchInfo.m_secondTouch, touchInfo.m_secondPoint, "dark");
                        chart.m_addingPlotChart = "";
                        chart.invalidate();
                    }
                }
            }
            else if (eventName == FCEventID.Click)
            {
                if (view.getName() == "Indicator")
                {
                    if (view.getText() == "BOLL" || view.getText() == "MA")
                    {
                        m_tChart.m_mainIndicator = view.getText();
                    }
                    else
                    {
                        m_tChart.m_showIndicator = view.getText();
                    }
                    m_tChart.calcChartIndicator();
                    FCTabView tabView = view.getParent().getParent().getParent() as FCTabView;
                    tabView.setSelectedIndex(0);
                    m_native.invalidate();
                }
                else if (view.getName() == "Plot")
                {
                    m_tChart.m_addingPlotChart = view.getText();
                    FCTabView tabView = view.getParent().getParent().getParent() as FCTabView;
                    tabView.setSelectedIndex(0);
                    m_native.invalidate();
                }
            }
        }
    }
}
